package study.spring.core.ioc._3_bean_assemble.propertyAssemble;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 用于演示 属性注入(field injection)
 * <p>
 * 其他注入方式: 构造器注入, setter 方法注入
 */
@Component
public class InjectWithConstructInjection {
  protected final Log log = LogFactory.getLog(getClass());

  /**
   * 使用 Auto
   */
  InjectProperty injectProperty;

  // 如果只有一个构造器不使用 @Autowired 也可以
  // 多个构造器, 需要制定构造器, 用这个构造器创建对象
  @Autowired
  public InjectWithConstructInjection(InjectProperty injectProperty) {
    this.injectProperty = injectProperty;
  }

  public InjectWithConstructInjection() {
    log.info("调用InjectWithConstructInjection的无参构造方法");
  }
}
